﻿@model IEnumerable<RoadFlow.Data.Model.AppLibrary>
@{
    ViewBag.Title = "List";
}
<form method="post" id="form1" >
<div class="querybar">
    <table cellpadding="0" cellspacing="1" border="0" width="100%">
        <tr>
            <td>
                应用名称：<input type="text" class="mytext" id="Title" name="title1" value="@ViewBag.Title1" style="width:150px" />
                应用地址：<input type="text" class="mytext" id="Address" name="address" value="@ViewBag.Address" style="width:220px" />
                <input type="submit" name="Search" value="&nbsp;&nbsp;查&nbsp;询&nbsp;&nbsp;" class="mybutton" />
                <input type="button" onclick="add(); return false;" value="添加应用" class="mybutton" />
                <input type="button" onclick="del(); return false;" value="删除所选" class="mybutton" />
            </td>
        </tr>
    </table>
</div>
<table class="mygrid">
    <thead>
        <tr>
            <th width="3%" sort="0"><input type="checkbox" onclick="checkAll(this.checked);" style="vertical-align:middle;" /></th>
            <th width="20%">应用名称</th>
            <th width="47%">应用地址</th>
            <th width="20%">应用分类</th>
            <th width="10%" sort="0">操作</th>
        </tr>
    </thead>
    <tbody>
    @{
    RoadFlow.Platform.Dictionary bdict = new RoadFlow.Platform.Dictionary();
    foreach (var app in Model)
    {
        <tr>
            <td><input type="checkbox" value="@app.ID" name="checkbox_app" /></td>
            <td>@app.Title</td>
            <td>@app.Address</td>
            <td>@bdict.GetTitle(app.Type)</td>
            <td><a class="editlink" href="javascript:void(0);" onclick="edit('@app.ID');return false;">编辑</a></td>
        </tr>
    }    
    }
    </tbody>
</table>
<div>@Html.Raw(ViewBag.Pager)</div>
</form>

<script type="text/javascript">
    var appid = '@ViewBag.AppID';
    var iframeid = '@ViewBag.TabID';
    var typeid = '@ViewBag.TypeID';
    var dialog = top.mainDialog;
    $(function ()
    {
        var dataGrid = new RoadUI.Grid({ table: $(".mygrid")});
    });
    function add()
    {
        dialog.open({ id: "window_" + appid.replaceAll('-', ''), title: "添加应用程序", width: 700, height: 380, url: top.rootdir + '/AppLibrary/Edit?1=1' + '@ViewBag.Query1', openerid: iframeid });
    }
    function edit(id)
    {
        dialog.open({ id: "window_" + appid.replaceAll('-', ''), title: "编辑应用程序", width: 700, height: 380, url: top.rootdir + '/AppLibrary/Edit?id=' + id + '@ViewBag.Query1', openerid: iframeid });
    }
    function checkAll(checked)
    {
        $("input[name='checkbox_app']").prop("checked", checked);
    }
    function del()
    {
        if ($(":checked[name='checkbox_app']").size() == 0)
        {
            alert("您没有选择要删除的项!");
            return false;
        }
        if (!confirm('您真的要删除所选应用吗?'))
        {
            return false;
        }
        $("#form1").attr("action", "Delete"+"@Html.Raw(Request.Url.Query)");
        $("#form1").submit();
        return true;
    }
</script>